﻿Imports System.Data.OleDb
Imports DTO
Public Class PhieuNhap_DAO

#Region "Lập phiếu nhập sách"
    Public Shared Function LapPhieu(ByVal phieu As PhieuNhap_DTO) As Integer
        Dim sql As String = String.Format("Insert Into PhieuNhap(NgayNhap) Values('{0}')", phieu.NgayNhap)
        Dim flag As Integer = DataProvider.ExcuteNonQuery(sql)
        Return flag
    End Function
#End Region

#Region "Nhập chi tiết phiếu nhập"
    Public Shared Function NhapChiTiet(ByVal mapn As Integer, ByVal masach As Integer, ByVal sl As Integer)
        Dim sql As String = String.Format("Insert Into CT_PhieuNhap(MaPhieuNhap,MaSach,SoLuong) Values({0},{1},{2})", mapn, masach, sl)
        Dim flag As Integer = DataProvider.ExcuteNonQuery(sql)
        Return flag
    End Function
#End Region

#Region "Load danh sách phiếu nhập"
    Public Shared Function LoadPhieuNhap() As DataTable
        Dim sql As String = "select * from PhieuNhap"
        Return DataProvider.ExcuteReader(sql)
    End Function
#End Region

#Region "Load phiếu nhập theo mã"
    Public Shared Function LoadPhieuNhapTheoMa(ByVal ma As Integer) As DataTable
        Dim sql As String = String.Format("select s.TenSach,ct.SoLuong from Sach s,CT_PhieuNhap ct where ct.MaSach = s.MaSach and ct.MaPhieuNhap = {0}", ma)
        Return DataProvider.ExcuteReader(sql)
    End Function
#End Region

End Class
